package cn.org.guhao.practice.kafka.listener;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * ConsumerListener
 *
 * @author guhao
 * @since 2020/5/2
 */
@Component
public class ConsumerListener {

  private static final Logger logger = LoggerFactory.getLogger(ConsumerListener.class);

  @KafkaListener(topics = {"test"})
  public void listen(ConsumerRecord record){
    String json = record.value().toString();
    logger.info("partition:[{}], offset:[{}], kafka consumer sessionListener session json:{}",record.partition(),record.offset(), json);
  }

}
